<%@ include file="/html/portlet/upe/estagio/init.jsp"%>
<%@page import="com.liferay.portal.kernel.dao.search.ResultRow"%>
<%@page import="com.liferay.portal.util.WebKeys"%>
<%@page import="br.upe.portlet.estagio.model.Professor"%>
<%@page import="br.upe.portlet.estagio.service.permission.SistemaPermission"%>
<%@page import="br.upe.portlet.estagio.util.Constantes"%>
<%@page import="com.liferay.portal.util.PortalUtil"%>

<%
	String currentURL = PortalUtil.getCurrentURL(request);

	ResultRow row = (ResultRow) request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);

	Professor entry = (Professor) row.getObject();
%>

<liferay-ui:icon-menu>
	<c:if test="<%= SistemaPermission.contains(permissionChecker, portletGroupId, entry, ActionKeys.UPDATE) %>">
		<portlet:renderURL windowState="<%= WindowState.MAXIMIZED.toString() %>" var="editURL">
			<portlet:param name="struts_action" value="/upe/estagio/cadastros" />
			<portlet:param name="<%=Constantes.CMD %>" value="<%= Constantes.ATUALIZAR_PROFESSOR %>" />
			<portlet:param name="matricula" value="<%= entry.getMatricula() %>" />
			<portlet:param name="redirect" value="<%= currentURL %>" />
		</portlet:renderURL>
		<liferay-ui:icon image="edit" url="<%= editURL %>" />
	</c:if>
	<c:if test="<%= UserPermissionUtil.contains(permissionChecker, userId, ActionKeys.UPDATE) %>">
		<portlet:renderURL windowState="<%= WindowState.MAXIMIZED.toString() %>" var="editUserURL">
			<portlet:param name="struts_action" value="/enterprise_admin/edit_user" />
			<portlet:param name="redirect" value="<%= redirect %>" />
			<portlet:param name="p_u_i_d" value="<%= String.valueOf(userId) %>" />
		</portlet:renderURL>

		<liferay-ui:icon image="edit" url="<%= editUserURL %>" />
	</c:if>
	<c:if test="<%= SistemaPermission.contains(permissionChecker, portletGroupId, entry, ActionKeys.PERMISSIONS) %>">
		<liferay-security:permissionsURL modelResource="<%= Professor.class.getName() %>"
			modelResourceDescription="<%= entry.getUser().getFirstName() %>"
			resourcePrimKey="<%= entry.getMatricula() %>" var="permissionsURL" />

		<liferay-ui:icon image="permissions" url="<%= permissionsURL %>" />
	</c:if>

	<c:if test="<%= SistemaPermission.contains(permissionChecker, portletGroupId, entry, ActionKeys.DELETE) %>">
		<portlet:actionURL 	windowState="<%= WindowState.MAXIMIZED.toString() %>" var="deleteURL">
			<portlet:param name="struts_action" value="/upe/estagio/cadastros" />
			<portlet:param name="<%= Constantes.CMD %>" value="<%= Constantes.ATUALIZAR_PROFESSOR %>" />
			<portlet:param name="redirect" value="<%= currentURL %>" />
			<portlet:param name="matricula" value="<%= entry.getMatricula() %>" />
		</portlet:actionURL>

		<liferay-ui:icon-delete url="<%= deleteURL %>" />
	</c:if>
</liferay-ui:icon-menu>